package com.whpost.api.controller.stamp;

import cn.dev33.satoken.stp.StpUtil;
import com.whpost.api.controller.BaseController;
import com.whpost.api.utils.ApiUtils;
import com.whpost.service.entity.tools.ResultInfo;
import com.whpost.service.service.stamp.StampCardOrderMxServices;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.text.ParseException;
import java.util.Map;


@RestController
@RequestMapping("/stamp/ordermx")
public class StampCardOrderMxController extends BaseController {

    @Resource
    StampCardOrderMxServices stampCardOrderMxServices;
    @Autowired
    public StampCardOrderMxController(StampCardOrderMxServices stampCardOrderMxServices) {
        super();
        setPerCode("stampordermx");
        setBaseServices(stampCardOrderMxServices);
    }

    /**
     * 查询页面
     * @return
     */
    @RequestMapping(value ="/xztp")
    public String xztp(String id, String token, HttpServletResponse httpServletResponse) throws IOException {
        StpUtil.checkPermission("stampordermx:query");
        String loginId  = (String)StpUtil.getLoginIdByToken(token);
        return stampCardOrderMxServices.xztp(loginId,id,httpServletResponse);
    }

    /**
     * 下载打包文件
     * @return
     */
    @RequestMapping(value ="/xzzip")
    public String xzzip(String id, String token, HttpServletResponse httpServletResponse) throws IOException, ParseException {
        StpUtil.checkPermission("stampordermx:query");
        String loginId  = (String)StpUtil.getLoginIdByToken(token);
        return stampCardOrderMxServices.xzzip(loginId,id,httpServletResponse);
    }

    /**
     * 打包
     * @return
     */
    @RequestMapping(value ="/zip")
    public ResultInfo zip(@RequestBody Map<String, Object> map) throws Exception {
        StpUtil.checkPermission("stampordermx:query");
        String loginId = ApiUtils.getLoginId();
        return stampCardOrderMxServices.zip(loginId,map);
    }
}
